//
//  NterceptionCell.m
//  timelyRain
//
//  Created by Jiafei Wei on 16/10/10.
//  Copyright © 2016年 Jiafei Wei. All rights reserved.
//

#import "NterceptionCell.h"
#import "DataTool.h"
#import "MBTUiColor.h"
@interface NterceptionCell()
@property (weak, nonatomic) IBOutlet UIImageView *tagImage;
@property (weak, nonatomic) IBOutlet UILabel *phone;
@property (weak, nonatomic) IBOutlet UILabel *time;
@property (weak, nonatomic) IBOutlet UILabel *type;
@property (weak, nonatomic) IBOutlet UILabel *typeNumber;
@property (weak, nonatomic) IBOutlet UILabel *local;
@end
@implementation NterceptionCell

- (void)awakeFromNib {
    [super awakeFromNib];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
}

//创建自定义可重用的cell对象
+(instancetype)setNterceptionCellWithTableView:(UITableView *)tableView
{
    static NSString *reuseId = @"NterceptionCell";
    NterceptionCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseId];
    if (cell == nil) {
        cell = [[[NSBundle mainBundle] loadNibNamed:@"NterceptionCell" owner:nil options:nil] lastObject];
    }
    return cell;
}

-(void)setMarkInfo:(MarkInfo *)markInfo{
    _markInfo =markInfo;
    _phone.text=_markInfo.number;
    _typeNumber.text=_markInfo.mark;
    _local.text=_markInfo.attribute;
    _time.text =[DataTool  timestampChaStringDate:[_markInfo.time longLongValue]];
    _type.text=@"您标注为";
    [self setTagStatus:_markInfo.mark];
}
//电话拦截的信息
-(void)setInterceptInfo:(InterceptInfo *)interceptInfo{
    //_interceptInfo =interceptInfo;
    _phone.text =interceptInfo.from;
    _typeNumber.text =interceptInfo.mark;
     _time.text =[DataTool timestampChaStringDate:[interceptInfo.time longLongValue]];
    _type.text=@"您标注为";
    _local.text=interceptInfo.attribution;
    [self setTagStatus:interceptInfo.mark];
}
-(void)setInterceptSmsInfo:(InterceptInfo *)interceptSmsInfo{
    //_interceptSmsInfo=interceptSmsInfo;
    _local.hidden=YES;
    _type.textColor =[UIColor colorwithHexString:@"#eca659"];//修改标记
    _typeNumber.textColor=[UIColor colorwithHexString:@"#999999"];
    
    NSString *typeValue =[interceptSmsInfo.mark stringByAppendingString:@"]"];
    typeValue =[@"[" stringByAppendingString:typeValue];
    _type.text =typeValue;
    _phone.text =interceptSmsInfo.from;
    _typeNumber.text=interceptSmsInfo.content;
    _time.text =[DataTool timestampChaStringDate:[interceptSmsInfo.time longLongValue]];
}
-(void)setTagStatus:(NSString *)mark{
    if ([mark isEqualToString:@"黑名单"]) {
        _tagImage.image =[UIImage imageNamed:@"-黑名单"];
    }else if([mark isEqualToString:@"骚扰电话"]){
         _tagImage.image =[UIImage imageNamed:@"骚扰电话"];
    }else if([mark isEqualToString:@"诈骗电话"]){
         _tagImage.image =[UIImage imageNamed:@"诈骗电话"];
    }else if([mark isEqualToString:@"房产中介"]){
         _tagImage.image =[UIImage imageNamed:@"房产中介"];
    }else if([mark isEqualToString:@"快递服务"]){
         _tagImage.image =[UIImage imageNamed:@"快递电话-0"];
    }else if([mark isEqualToString:@"快餐电话"]){
         _tagImage.image =[UIImage imageNamed:@"快餐电话"];
    }else{
         _tagImage.image =[UIImage imageNamed:@"自定义图标"];
    }
}
@end
